﻿using System;
using System.Web.UI.WebControls;
using Bingosoft.Modules.SecurityConsole.Role;
using Bingosoft.Web.Utils;

namespace Bingosoft.WebApp.Modules.SecurityConsole.Role
{
    public partial class RoleInherit : System.Web.UI.BasePage
    {
        private RoleService _roleService;
        private RoleService RoleService
        {
            get { return _roleService ?? (_roleService = ObjectHelper.GetObject<RoleService>()); }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void SearchGrid(object sender, EventArgs e)
        {
            SmartGridView1.PageIndex = 0;
            SmartGridView1.DataBind();
        }


        protected void RemoveRoleInhert(object sender, EventArgs e)
        {
            ImageButton img = (ImageButton)sender;

            string parentRoleId = img.Attributes["_KeyId"];
            string childRoleId = Request.Params["RoleId"];

            this.RoleService.DeleteRolesInherit(childRoleId, new string[] { parentRoleId });
            SmartGridView1.DataBind();
        }

        protected void RemoveRolesInherit(object sender, EventArgs e)
        {
            string childRoleId = Request.Params["RoleId"];
            string[] parentRoleIds = SmartGridView1.GetCheckedValues();

            this.RoleService.DeleteRolesInherit(childRoleId, parentRoleIds);
            SmartGridView1.DataBind();
        }
    }
}